-
Notifications
You must be signed in to change notification settings - Fork 1k
Add ADC internal channels #539
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Signed-off-by: Frederic.Pillon <[email protected]>
ADC_SAMPLINGTIME and ADC_CLOCK_DIV could be redefined by the variant or using build_opt.h. Signed-off-by: Frederic.Pillon <[email protected]>
Signed-off-by: Frederic.Pillon <[email protected]>
Fix stm32duino#474 Signed-off-by: Frederic.Pillon <[email protected]>
Internal channels use is enabling ADC "internal path" which needs to be disabled after measurement Signed-off-by: Frederic Pillon <[email protected]>
e9de3ec
to
ef20dc8
Compare
Thanks for this @fpistm ! Just a minor comment on the example code... isn't VBAT internally scaled down before it is fed to the ADC? I know there is a 3x divider in the STM32L43x/L45x etc. not sure about the other families. |
Welcome @ppescher |
#ifdef AVBAT
Serial.print("\tVbat(mv)= ");
Serial.print(readVoltage(VRef, AVBAT));
#endif should be
|
This PR add support of the following internal channels (ST HAL definitions):
ADC_CHANNEL_TEMPSENSOR
ADC_CHANNEL_VREFINT
ADC_CHANNEL_VBAT
analogRead()
can now be used with the following definitions:ATEMP
AVREF
AVBAT
A minimum ADC sampling time is required when reading internal channels so default is set it to max possible value. It can be defined more precisely by defining:
ADC_SAMPLINGTIME_INTERNAL
to the desired ADC sample time.
This PR also add some hardening:
ADC_HandleTypeDef
andADC_ChannelConfTypeDef
management across seriesADC_SAMPLINGTIME
andADC_CLOCK_DIV
could be redefined by the variant or usingbuild_opt.h
.Fix #474
Hereafter an usage example which read then convert to proper Unit the 3 internal channels + A0: